# 事件绑定
import json

class EventStore:
    
    def __init__(self):
        self.__store = {}
    
    def getStore(self):
        return self.__store
    
    
    def bind(self, eventName, callback):
        store = self.__store

        if not eventName in store:
            store[eventName] = [callback]
        else:
            store[eventName].append(callback)
        
            
    def target(self, eventName, event):
        
        eventList = self.EventList(eventName)

        if len(eventList) > 0:
            for item in eventList:
                item(event)
        

    def remove(self, eventName):
        if self.hasEvent(eventName):
            self.__store[eventName] = []

    def hasEvent(self, eventName):
        return eventName in self.__store


    def EventList(self, eventName):
        arr = []

        if self.hasEvent(eventName):
            arr = self.__store[eventName]

        return arr
